import 'dart:convert';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_yres/model/shop/hdk_list_model.dart';
import 'package:dio/dio.dart';
import 'package:flutter_yres/tool/constant.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_yres/tool/network/http_method.dart';
import 'package:flutter_yres/tool/network/http_url.dart';
import 'package:flutter_yres/pages/shop/shop_detail_page.dart';
import 'package:cached_network_image/cached_network_image.dart';
import './jd_list_page.dart';



class JDPage extends StatefulWidget {
  JDPage({Key key}) : super(key: key);

  @override
  _JDPageState createState() => _JDPageState();
}

class _JDPageState extends State<JDPage> {
  List tabs = [];
  TabController _tabController;
  @override
  Widget build(BuildContext context) {
    return new DefaultTabController(
        length: tabs.length,
        child: Scaffold(
          appBar: AppBar(
            title:
                Text('京东', style: TextStyle(fontSize: 18, color: black)),
            backgroundColor: white,
            brightness: Brightness.light,
            iconTheme: IconThemeData(color: black_99),
            elevation: 1.0,
            bottom: TabBar(
              labelColor: black,
              isScrollable: true,
              tabs: tabs.map((item) {
                return _tabsBuilder(context, item);
              }).toList(),
              controller: _tabController,
              onTap: (index) {
                // print(tabs[index].pdd_id);
              },
            ),
          ),
          body: TabBarView(
            children: tabs.map<Widget>((item) {
              // print(item.name);
              // print(item.pdd_cat_id);
              // print(item.pdd_id);
              return JDListPage(
                // type: widget.type,
                // name: widget.name,
                // cid: item['cid'],
              );
            }).toList(),
          ),
        )
        );
  }

    Widget _tabsBuilder(BuildContext context, item) {
    return Tab(text: item['name']);
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  getjdtop()async{
    // '/app.php?c=JingdongCat&a=getTopCatList'
  }
}